package state;

import main.Game;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;

import button.Button;
import button.StandardButton;
import constans.Flag;
import constans.ResourceManager;

public class MultiplayerState extends State{

	Button back;
	private Button[] button;
	
	public MultiplayerState()
	{
		background = ResourceManager.getImage("background");
		
		back = new StandardButton(310,490,200,50,Flag.MENU_STATE,ResourceManager.getImage("b_back"),ResourceManager.getSound("click"));
		buttonsBcg = ResourceManager.getImage("menu_buttonsBcg");
		button = new Button[2];
		button[0] = new StandardButton(310,250,200,50,Flag.SINGLEPLAYER_STATE,ResourceManager.getImage("b_newGame"),ResourceManager.getSound("click"));
		button[1] = new StandardButton(310,310,200,50,Flag.MULTIPLAYER_STATE,ResourceManager.getImage("b_join"),ResourceManager.getSound("click"));
		
	}
	
	public void render(GameContainer container, Graphics g) throws SlickException
	{	
		super.render(container, g);
		
		buttonsBcg.draw(300, 240);
		back.render(container, g);
		for(Button b:button)
			b.render(container, g);
	}
	public void update(GameContainer container, int delta) throws SlickException
	{
		Input input = container.getInput();
		
		back.hover(input);
		stateFlag = back.click(input);
		if(back.wasClicked()) Game.setState(stateFlag);
		
		for(Button b:button)
		{
			b.hover(input);
			stateFlag = b.click(input);
			if(b.wasClicked()) Game.setState(stateFlag);
		}
			
	}
}
